package com.thp.factory.abstr;

import com.thp.factory.Audi;
import com.thp.factory.Benz;
import com.thp.factory.Bmw;
import com.thp.factory.Car;

/**
 * 抽象工厂
 * 自带了逻辑
 * @author Tommy
 *
 */
public abstract class AbstractFactory {

	protected abstract Car getCar();
	
	// 这段代码就是动态配置的功能
	public Car getCar(String name) {
		if("BMW".equalsIgnoreCase(name)) {
			return new BmwFactory().getCar();
		} else if ("BENZ".equalsIgnoreCase(name)) {
			return new BenzFactory().getCar();
		} else if("Audi".equals(name)) {
			return new AudiFactory().getCar();
		} 
		System.out.println("无工厂生产该产品");
		return null;
	}
}
